const app = getApp();
Page({
    data: {
      translateTools:[
        {
          "name":"拍照翻译",
          "icon":"/image/tool/camera.jpg",
          "bg_color":"bg_color_1",
          "url": "/pages/translation/photo/photo"
        },
        {
          "name": "文本翻译",
          "icon": "/image/tool/fanyi.jpg",
          "bg_color": "bg_color_1",
          "url":"/pages/translation/text/text"
        },
        {
          "name": "单词词典",
          "icon": "/image/tool/dictionary.jpg",
          "bg_color": "bg_color_1",
          "url": "/pages/translation/word/word"
        }
        
      ],

      voiceTools:[
        {
          "name": "同声传译",
          "desc": "再也不怕和老外对话了",
          "icon": "/image/tool/ai_android.jpg",
          "bg_color": "bg_color_2",
          "url": "/pages/tongsheng/tongsheng"
        },
        {
          "name": "人工智能",
          "desc": "快来和幽默的机器人聊天吧",
          "icon": "/image/tool/ai_android.jpg",
          "bg_color": "bg_color_2",
          "url": "/pages/tools/chat/index"
        }
      ],
      wordTools: [
        {
          "name": "单词测评",
          "desc": "四万多单词量分级测评",
          "icon": "/image/tool/ai_tutor.jpg",
          "bg_color": "bg_color_4",
          "url": "/pages/tools/word-test/word-test-index?type=word"
        },
        {
          "name": "词组测评",
          "desc": "两万词组量分级测评",
          "icon": "/image/tool/ai_tutor.jpg",
          "bg_color": "bg_color_4",
          "url": "/pages/tools/word-test/word-test-index?type=phrase"
        }
      ]
    },
    
  onLoad: function (options) {
   
    if (null != app.globalData.openid) {
      return;
    }

    //用户登陆记录openid
    // 调用云函数
    wx.cloud.callFunction({
      name: 'login',
      data: {},
      success: res => {
        console.log('[云函数] [login] user openid: ', res.result.openid)
        app.globalData.openid = res.result.openid;
        
      },
      fail: err => {
        console.error('[云函数] [login] 调用失败', err)
      }
    })
  }, 
  onShareAppMessage: function () {

  }
});